{extend name="base/base" /}
{block name="style"}
<style type="text/css">
.layui-table-cell{
     height: auto!important;
     white-space: normal;
}
</style>
{/block}
{block name="content"}
  <div class="layui-form-item layui-form-pane">
      <!-- <div class="layui-inline">
      <label class="layui-form-label">认证状态</label>
      <div class="layui-input-inline">
        <select class="layui-input" name='identity_status' id='identity_status'>
          <option value="">全部</option>
          <option value="0">未认证</option>
          <option value="1">待审核</option>
          <option value="2">已认证</option>
          <option value="3">认证失败</option>
        </select>
      </div>
    </div> -->
    <div class="layui-inline">
      <label class="layui-form-label">账号状态</label>
      <div class="layui-input-inline">
        <select class="layui-input" name='status' id='status'>
          <option value="">全部</option>
          <option value="1">正常</option>
          <option value="0">冻结</option>
        </select>
      </div>
    </div>
      <div class="layui-inline">
          <label class="layui-form-label">用户ID</label>
          <div class="layui-input-inline">
              <input type="text" name="id" autocomplete="off" class="layui-input" id='id'>
          </div>
      </div>
      <div class="layui-inline">
          <label class="layui-form-label">上级ID</label>
          <div class="layui-input-inline">
              <input type="text" name="ppid" autocomplete="off" class="layui-input" id='ppid'>
          </div>
      </div>
      <div class="layui-inline">
          <label class="layui-form-label">手机号码</label>
          <div class="layui-input-inline">
              <input type="text" name="phone" autocomplete="off" class="layui-input" id='phone'>
          </div>
      </div>
      <div class="layui-inline">
          <label class="layui-form-label">团队ID</label>
          <div class="layui-input-inline">
              <input type="text" name="uuid" autocomplete="off" class="layui-input" id='uuid'>
          </div>
      </div>
      <div class="layui-inline">
          <label class="layui-form-label">钱包地址</label>
          <div class="layui-input-inline">
              <input type="text" name="address" autocomplete="off" class="layui-input" id='address'>
          </div>
      </div>
      <div class="layui-inline">
      <label class="layui-form-label">用户来源</label>
      <div class="layui-input-inline">
        <select class="layui-input" name='quhao' id='quhao'>
          <option value="">全部</option>
          <option value="91">印度</option>
          <option value="62">印尼</option>
        </select>
      </div>
    </div>
      <div class="layui-inline">
          <label class="layui-form-label">用户等级</label>
          <div class="layui-input-inline">
              <input type="text" name="level" autocomplete="off" class="layui-input" id='level'>
          </div>
      </div>
       <div class="layui-inline">
          <label class="layui-form-label">余额大于</label>
          <div class="layui-input-inline">
              <input type="text" name="ye1" autocomplete="off" class="layui-input" id='ye1'>
          </div>
      </div>
      <div class="layui-inline">
          <label class="layui-form-label">余额小于</label>
          <div class="layui-input-inline">
              <input type="text" name="ye2" autocomplete="off" class="layui-input" id='ye2'>
          </div>
      </div>
      <!-- <div class="layui-inline">
      <label class="layui-form-label">智能云状态</label>
      <div class="layui-input-inline">
        <select class="layui-input" name='status' id='status'>
          <option value="">全部</option>
          <option value="1">正常</option>
          <option value="0">冻结</option>
        </select>
      </div>
    </div> -->
      <div class="layui-inline">
          <label class="layui-form-label">智能云等级</label>
          <div class="layui-input-inline">
              <input type="text" name="robot_level" autocomplete="off" class="layui-input" id='robot_level'>
          </div>
      </div>
      <div class="layui-inline">
          <label class="layui-form-label">注册时间</label>
          <div class="layui-input-inline">
              <input type="text" class="layui-input" name="start_time" id="start_time" placeholder="yyyy-MM-dd">
          </div>
          <div class="layui-form-mid">-</div>
          <div class="layui-input-inline">
              <input type="text" class="layui-input" name="end_time" id="end_time" placeholder="yyyy-MM-dd">
          </div>
      </div>
      <div class="layui-inline">
        <div class="demoTable">
          <button class="layui-btn" data-type="reload">搜索</button>
          <button class="layui-btn" onclick="excel()">导出表</button>
          <!-- <a href="team1.html" target="_blank" class="layui-btn">会员图</a> -->
          <!-- <a href="team2.html" target="_blank" class="layui-btn">会员双轨图</a> -->
        </div>
      </div>
  <table id="table" lay-filter="table"></table>
  <script type="text/html" id="zfxx">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="zfxx">查看</a>
  </script>
  <script type="text/html" id="rzxx">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="rzxx">查看</a>
  </script>
  <script type="text/html" id="tdjg">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="tdjg">查看</a>
  </script>
  <script type="text/html" id="yj">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="yj">查看</a>
  </script>
  <script type="text/html" id="tbed">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="tbed">查看</a>
  </script>
  <script type="text/html" id="edit">
    <!-- <a class="layui-btn layui-btn-xs" lay-event="rzxx">认证</a> -->
    <!-- <a class="layui-btn layui-btn-xs" lay-event="jdj">冻结/解冻</a> -->
    <a class="layui-btn layui-btn-xs" lay-event="bb">资产</a>
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <!-- <a class="layui-btn layui-btn-xs" lay-event="del">删除</a> -->
  </script>
</div>
{/block}
{block name="script"}
<script>
layui.use(['table', 'laydate'], function(){
  var table = layui.table;
  var laydate = layui.laydate;
  table.render({
    elem: '#table'
    ,height: 'full-200'
    ,url: '/admin/user/dataList/?{$type}={$id}'//数据接口
    ,limit:20
    ,page: true //开启分页
    ,id:'table'
    ,cols: [[ //表头
      {field:'id', title: '用户ID', width: 100, fixed: 'left'}
      // ,{field:'avatar', title: '头像', width: 80,templet: function(d){
      //   return '<img src="'+d.avatar+'" style="width:50px;height:50px">'
      // }}
      // ,{field:'username', title: '用户名', width: 150}
      ,{field:'phone', title: '电话', width: 150,fixed: 'left',templet: function(d){
          return d.quhao + d.phone;
      }}
      ,{field:'pid', title: '上级ID', width: 100}
      ,{field:'v_name', title: '上级用户', width: 150,templet: function(d){
        if(d.v_name == null){
          return '<span style="color:red">初始号</span>'
        } else {
          return '<a style="color:blue" href="/admin/user/index?pid='+d.invite_uid+'">'+d.v_name+'</a>'
        }
      }}
      ,{field:'zk', title: '直推人数', width: 100,templet: function(d){
          return '<a style="color:blue" href="/admin/user/index?uid='+d.id+'">'+d.zk+'</a>'
      }}
      // ,{field:'quhao', title: '区号', width: 100}
      
       ,{field:'invite_code', title: '邀请码', width: 100}
       ,{field:'reg_date', title: '注册时间', width: 200}
       ,{field:'robot_name', title: '智能云等级', width: 200}
       ,{field:'balance', title: 'USDT余额', width: 100}
       ,{field:'level_name', title: '等级', width: 100}
       ,{field:'vip_date', title: '等级过期时间', width: 200}
       ,{field:'vip_update_date', title: '等级更新时间', width: 200}
       ,{field:'vip_next_days', title: 'vip天数', width: 100}
       

      
      ,{field:'robot_status', title: '智能云状态', width: 150,templet: function(d){
        if (d.robot_status == 1) {
          return '<span style="color:green">关闭</span>'
        }
        if (d.robot_status == 2) {
          return '<span style="color:red">启动</span>'
        }
      }}
      ,{field:'static_profit_status', title: '静态收益状态', width: 150,templet: function(d){
        if (d.static_profit_status == 1) {
          return '<span style="color:red">正常</span>'
        }
        if (d.static_profit_status == 0) {
          return '<span style="color:green">禁止</span>'
        }
      }}
      ,{field:'invite_profit_status', title: '推广收益状态', width: 150,templet: function(d){
        if (d.invite_profit_status == 1) {
          return '<span style="color:red">正常</span>'
        }
        if (d.invite_profit_status == 0) {
          return '<span style="color:green">禁止</span>'
        }
      }}
      ,{field:'team_profit_status', title: '团队收益状态', width: 150,templet: function(d){
        if (d.team_profit_status == 1) {
          return '<span style="color:red">正常</span>'
        }
        if (d.team_profit_status == 0) {
          return '<span style="color:green">禁止</span>'
        }
      }}
      ,{field:'out_status', title: '提币状态', width: 100,templet: function(d){
        if (d.out_status == 1) {
          return '<span style="color:red">正常</span>'
        }
        if (d.out_status == 0) {
          return '<span style="color:green">禁止</span>'
        }
      }}
      ,{field:'status', title: '账号状态', width: 100,templet: function(d){
        if (d.status == 1) {
          return '<span style="color:red">正常</span>'
        }
        if (d.status == 0) {
          return '<span style="color:green">异常</span>'
        }
      }}
      ,{title: '团队结构', toolbar: '#tdjg', width: 100}
      ,{title: '操作', toolbar: '#edit', width: 200}
    ]]
  }); 
  laydate.render({
    elem: '#start_time'
  });
  laydate.render({
    elem: '#end_time'
  });
  // 搜索
  var $ = layui.$, active = {
        reload: function(){
            table.reload('table', {
                where: {
                    status: $('#status').val(),
                    phone: $('#phone').val(),
                    address: $('#address').val(),
                    username: $('#username').val(),
                    id: $('#id').val(),
                    ppid: $('#ppid').val(),
                    level: $('#level').val(),
                    robot_level: $('#robot_level').val(),
                    start_time: $('#start_time').val(),
                    end_time: $('#end_time').val(),
                    ye1: $('#ye1').val(),
                    ye2: $('#ye2').val(),
                    uuid: $('#uuid').val(),
                    quhao: $('#quhao').val(),
                }
            });
        }
    };
    $('.demoTable .layui-btn').on('click', function(){
    var type = $(this).data('type');
    active[type] ? active[type].call(this) : '';
  });

  //编辑 删除
  table.on('tool(table)', function(obj){
    var data = obj.data;

    //编辑
    if(obj.event === 'edit'){
      layer.open({
        type: 2 ,
        title: '编辑',   //标题
        area: ['500px', '800px'],   //宽高
        shade: 0.4,   //遮罩透明度
        content: '/admin/user/editUser?id='+data.id,//支持获取DOM元素
        // end:function(){
        //   $(".layui-laypage-btn")[0].click();
        // }
        });
    }

    //拨币
    if(obj.event === 'bb') {
      layer.open({
        type: 2 ,
        title: '资产   会员 : '+data.username,   //标题
        area: ['1080px', '600px'],   //宽高
        shade: 0.4,   //遮罩透明度
        content: '/admin/user/bb?id='+data.id,//支持获取DOM元素
        });
    }
    if(obj.event === 'tdjg'){
      layer.open({
        type: 2 ,
        title: '团队结构 会员 : '+data.username,   //标题
        area: ['500px', '500px'],   //宽高
        shade: 0.4,   //遮罩透明度
        content: '/admin/user/team?username='+data.username,//支持获取DOM元素
        });
    }

  });
  ///监听单元格编辑 ,edit: 'text'
});
function excel(){
  var post_data = {
                    status: $('#status').val(),
                    phone: $('#phone').val(),
                    address: $('#address').val(),
                    username: $('#username').val(),
                    id: $('#id').val(),
                    ppid: $('#ppid').val(),
                    level: $('#level').val(),
                    robot_level: $('#robot_level').val(),
                    start_time: $('#start_time').val(),
                    end_time: $('#end_time').val(),
                    quhao: $('#quhao').val(),
                }
  $.ajax({
    url:"/admin/user/Excel",
    type:"POST",
    data:post_data,
    success:function(ret){
      //alert(ret);
      location.href='/'+ret;
    }
}); 
}
</script>
{/block}
